<template>
  <div class="message">
    <div class="header">热门帖子</div>
    <div class="message-list">
      <div class="img-list" v-for="(item, index) in dataList" :key="index" @click="openLink(item)">
        <div class="image-box">
          <img class="image" :src="item.file_path" alt>
        </div>
        <p class="massage-header one-txt-cut">{{ item.title }}</p>
        <div class="peronNum">
          <div class="icon-box">
            <img
              class="iconfont-img"
              src="https://gw.alicdn.com/tfs/TB1DW6AUNnaK1RjSZFtXXbC2VXa-18-16.jpg"
            >
            <span class="icon-text">{{item.collect_nums || 0}}</span>
          </div>
          <div class="icon-box">
            <img
              class="iconfont-img"
              src="https://gw.alicdn.com/tfs/TB1e6zXUMHqK1RjSZFPXXcwapXa-21-17.png"
            >
            <span class="icon-text">{{item.comment_nums || 0}}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getListPortalTops } from "@/api/home";

export default {
  name: "sqbxOthers",
  data() {
    return {
      listQuery: {
        current: 1,
        limit: 8,
        company_id: localStorage.getItem("companyId") - 0
      },
      dataList: []
    };
  },
  methods: {
    openLink(item) {
      if (item.type == "draw") {
        this.$router.push({ path: "/Trunplate1", query: { drawId: item.id } });
      }
      if (item.type == "active") {
        this.$router.push({
          path: "/ActivityDetail",
          query: { id: item.id, status: item.active_status, name: "home" }
        });
      }
      if (item.type == "article") {
        this.$router.push({
          path: "/CommunityDetail",
          query: { id: item.id, name: "article" }
        });
      }
      if (item.type == "proposal") {
        this.$router.push({
          path: "/proposalDetail",
          query: { id: item.id, name: "proposal" }
        });
      }
      if (item.vote_type == 1) {
        this.$router.push({ path: "/VoteTypeTwo", query: { id: item.id } });
      }
      if (item.vote_type == 2) {
        this.$router.push({ path: "/VoteTypeThree", query: { id: item.id } });
      }
      if (item.type == "questionnaire") {
        this.$router.push({ path: "/SurveyDetails", query: { id: item.id } });
      }
    },
    async initList() {
      let query = Object.assign({}, this.listQuery);
      let res = await getListPortalTops(query);
      let result = res.data;
      if (result.status == 100) {
        this.dataList = result.data.rows;
      }
    }
  },
  created() {
    setTimeout(() => {
      this.initList();
    }, 1000);
  }
};
</script>

<style lang="scss" scoped>
.message {
  background: rgb(243, 248, 252);
  padding: 13px 8px;
  .header {
    padding-left: 10px;
    font-size: 18px;
    font-weight: 600;
    color: #3a3a3a;
  }
  .message-list {
    width: 100%;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    .img-list {
      //   height: 108px;
      width: 173px;
      margin-top: 8px;
      background-color: #fff;
      border-radius: 5px;
      overflow: hidden;
      box-shadow: 0 0 2px 1px #ccc;
    }
    .image-box {
      width: 100%;
    }
    .image {
      width: 100%;
    }
    .massage-header {
      padding: 6px 5px 0;
      font-size: 13px;
      color: #3a3a3a;
    }
    .peronNum {
      padding: 0 5px 5px;
      display: flex;
      align-items: center;
      .icon-box {
        margin-right: 15px;
        display: flex;
        align-items: center;
      }
      .iconfont-img {
        margin-top: 5px;
        width: 12px;
      }
      .icon-text {
        font-size: 12px;
        color: #a0a0a0;
        margin-top: 6px;
        padding-left: 6px;
      }
    }
  }
}
</style>
